-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip leading trailing empty lines in doc code blocks #103376
base: master
Are you sure you want to change the base?
Strip leading trailing empty lines in doc code blocks #103376
Conversation
r? @notriddle (rust-highfive has picked a reviewer for you, use r? to override) |
|
||
<span class="comment">// bye</span></code></pre></div> | ||
"#, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case with boring lines at the start and end, since these are the use cases that actually motivate this feature.
t(
"\
```
# hello
f();
# goodbye
```",
r#"
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>f();</code></pre></div>
"#,
);
On a broader note, I don't really like this approach, since the CommonMark spec specifically says that empty lines in fenced code blocks are supposed to be preserved, even if the entire code block is nothing but newlines. But it probably doesn't matter in practice. |
Hence why I'm asking everyone's opinion on this. This is the simplest approach but we can also only remove commented lines and keep all the others or have a mix and remove lines if it starts or ends with commented lines. |
☔ The latest upstream changes (presumably #105554) made this pull request unmergeable. Please resolve the merge conflicts. |
Fixes #102996.
We currently have an inconsistent way of handling leading and trailing empty lines in doc code blocks (some examples in the linked issue). With this PR, I propose to remove all of them, whether there is hidden code or not. So for example:
will be rendered like this:
What do you think @rust-lang/rustdoc ?